﻿
@{
    ViewBag.Title = "点评管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section styles{
    <link href="~/bootstrap/plugins/bootstrap-table/bootstrap-table.css" rel="stylesheet" />
}

@section scripts{
    <script type="text/javascript" src="~/bootstrap/plugins/bootstrap-table/bootstrap-table.js"></script>
    <script src="~/bootstrap/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.js"></script>

    <script src="~/js/admin.js?v=2.0"></script>
    <script type="text/javascript">
        var $table = $("#bsTable");
        $(function () {
            $table.bootstrapTable({
                url: "@Url.Action("GetList")",
                pagination: true,
                pageSize: 10,
                singleSelect: true,//复选框只能选中一个
                clickToSelect: true,//单击行勾选复选框
                queryParams: queryParams
            });
        });

        function queryParams(params) {
            return {
                PageIndex: params.offset / params.limit + 1,
                PageSize: params.limit,
                Key: $("#Key").val(),
                comment_type: $("#comment_type").val()
            };
        }

        function Search() {
            $table.bootstrapTable("refreshOptions", {
                pageNumber: 1,
                queryParams: queryParams
            });
        }
        function titleFormatter(value, row, index) {
            return '<a href="@Url.Action("Detail")?id=' + row.id + '&comment_type=' + row.comment_type+'" > '+value+' </a>';
        }

         function replyFormatter(value, row, index) {
             return '<a href="@Url.Action("Index","Reply")?commentid=' + row.id + '" > '+value+' </a>';
        }

        function isAnonymousFormatter(value, row, index) {
            if (value == 1) {
                return "非匿名";
            } else if (value == 2) {
                return "匿名"
            } else {
                return "";
            }
        }


    </script>

}

<ul class="page-breadcrumb breadcrumb">
    <li>
        <a href="#">
            点评管理
        </a>
    </li>
</ul>

<div class="row">
    <div class="col-md-12">

        <div class="portlet-body">
            <div class="row">
                <div class="form-group">
                    <div class="col-sm-4">

                    </div>
                    <div class="col-sm-4">
                        <select id="comment_type" name="comment_type" class="form-control">
                            @if (ViewBag.CommentType != null)
                            {
                                foreach (var item in ViewBag.CommentType as IList<KeyValuePair<int, string>>)
                                {
                                    <option value="@(item.Key)">@(item.Value)</option>
                                }
                            }
                        </select>
                    </div>
                    <div class="col-sm-4">
                        <div class="input-group">
                            <div>
                                <input id="Key" class="form-control" type="text" placeholder="标题、内容" />
                            </div>
                            <span class="input-group-btn">
                                <button class="btn btn-success" onclick="Search();" type="button"><i class="fa fa-search"></i> 查询</button>
                            </span>
                        </div>
                    </div>
                </div>
            </div><br />
            <table id="bsTable">
                <thead>
                    <tr>
                        @*<th data-checkbox="true"></th>*@

                        <th data-field="title" data-formatter="titleFormatter">标题</th>
                        <th data-field="content">内容</th>
                        <th data-field="username">点评人</th>
                        <th data-field="tagname">点评标签</th>
                        <th data-field="relatename">商户|商品名称</th>
                        <th data-field="likecount">点赞数</th>
                        <th data-field="replycount" data-formatter="replyFormatter">评论数</th>
                        <th data-field="createtime">时间</th>
                        <th data-field="is_anonymous" data-formatter="isAnonymousFormatter">是否匿名</th>
                        <th data-field="is_audit" data-formatter="auditFormatter">是否审核</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</div>


